package com.wj.rpsm.admin.controller;

import com.wj.rpsm.admin.pojo.PageResult;
import com.wj.rpsm.admin.service.BuildingService;
import com.wj.rpsm.admin.pojo.Building;
import com.wj.rpsm.admin.pojo.ResponsePojo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author WeiJin
 * @version 1.0
 */
@Api(tags = "楼栋相关接口")
@RestController
public class BuildingController {
    @Autowired
    private BuildingService buildingService;

    @ApiOperation(value = "查询楼栋分页信息",
            response = Building.class,
            responseContainer = "list",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "current", value = "当前页数",
                    defaultValue = "1", dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "size", value = "页面行数",
                    dataType = "Integer", paramType = "query", defaultValue = "10")
    })
    @GetMapping("/page/building")
    public ResponsePojo<PageResult<Building>> pageOfBuilding(
            @RequestParam(name = "current" , required = false , defaultValue = "1" ) Integer current,
            @RequestParam(name = "size" , required = false, defaultValue = "10") Integer size,
            @RequestParam(name = "key" , required = false)String key) {
        PageResult<Building> result = buildingService.pageOfBuilding(current, size,null);
        return ResponsePojo.success(result);
    }
}
